using System;
using System.IO.Packaging;
using System.Workflow.ComponentModel;
using System.ComponentModel;

namespace OWA.Activities
{
	public class CorePropertiesActivity
        : AbstractPackageActivity
	{
        public static DependencyProperty CategoryProperty = DependencyProperty.Register("Category", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty ContentStatusProperty = DependencyProperty.Register("ContentStatus", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty ContentTypeProperty = DependencyProperty.Register("ContentType", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty CreatedProperty = DependencyProperty.Register("Created", typeof(DateTime?), typeof(CorePropertiesActivity));
        public static DependencyProperty CreatorProperty = DependencyProperty.Register("Creator", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty DescriptionProperty = DependencyProperty.Register("Description", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty IdentifierProperty = DependencyProperty.Register("Identifier", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty KeywordsProperty = DependencyProperty.Register("Keywords", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty LanguageProperty = DependencyProperty.Register("Language", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty LastModifiedByProperty = DependencyProperty.Register("LastModifiedBy", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty LastPrintedProperty = DependencyProperty.Register("LastPrinted", typeof(DateTime?), typeof(CorePropertiesActivity));
        public static DependencyProperty ModifiedProperty = DependencyProperty.Register("Modified", typeof(DateTime?), typeof(CorePropertiesActivity));
        public static DependencyProperty RevisionProperty = DependencyProperty.Register("Revision", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty SubjectProperty = DependencyProperty.Register("Subject", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(CorePropertiesActivity));
        public static DependencyProperty VersionProperty = DependencyProperty.Register("Version", typeof(string), typeof(CorePropertiesActivity));

        [Description("The category of the document.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Category
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.CategoryProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.CategoryProperty, value);
            }
        }

        [Description("The status of the document.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string ContentStatus
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.ContentStatusProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.ContentStatusProperty, value);
            }
        }

        [Description("The content type of the document.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string ContentType
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.ContentTypeProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.ContentTypeProperty, value);
            }
        }

        [Description("The date the document was created.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public DateTime? Created
        {
            get
            {
                return ((DateTime?)(base.GetValue(CorePropertiesActivity.CreatedProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.CreatedProperty, value);
            }
        }

        [Description("The one who created the document.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Creator
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.CreatorProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.CreatorProperty, value);
            }
        }

        [Description("A text describing the document content.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Description
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.DescriptionProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.DescriptionProperty, value);
            }
        }

        [Description("A unique identifier for the document.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Identifier
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.IdentifierProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.IdentifierProperty, value);
            }
        }

        [Description("A set of keywords describing the document content.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Keywords
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.KeywordsProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.KeywordsProperty, value);
            }
        }

        [Description("The language the document is in.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Language
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.LanguageProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.LanguageProperty, value);
            }
        }

        [Description("The one who last modified the document.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string LastModifiedBy
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.LastModifiedByProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.LastModifiedByProperty, value);
            }
        }

        [Description("The date of the last time that the document was printed.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public DateTime? LastPrinted
        {
            get
            {
                return ((DateTime?)(base.GetValue(CorePropertiesActivity.LastPrintedProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.LastPrintedProperty, value);
            }
        }

        [Description("The date of the last time the document was modified.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public DateTime? Modified
        {
            get
            {
                return ((DateTime?)(base.GetValue(CorePropertiesActivity.ModifiedProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.ModifiedProperty, value);
            }
        }

        [Description("The document revision number.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Revision
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.RevisionProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.RevisionProperty, value);
            }
        }

        [Description("What subject the document is about.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Subject
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.SubjectProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.SubjectProperty, value);
            }
        }

        [Description("The title of the document.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Title
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.TitleProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.TitleProperty, value);
            }
        }

        [Description("The title of the document.")]
        [Category("Document Properties")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Version
        {
            get
            {
                return ((string)(base.GetValue(CorePropertiesActivity.VersionProperty)));
            }
            set
            {
                base.SetValue(CorePropertiesActivity.VersionProperty, value);
            }
        }

        protected override ActivityExecutionStatus Execute(
            ActivityExecutionContext executionContext)
        {
            Package package = GetPackage();
            string category = Category;
            if (String.IsNullOrEmpty(category) == false)
            {
                package.PackageProperties.Category = category;
            }
            string contentStatus = ContentStatus;
            if (String.IsNullOrEmpty(contentStatus) == false)
            {
                package.PackageProperties.ContentStatus = contentStatus;
            }
            string contentType = ContentType;
            if (String.IsNullOrEmpty(contentType) == false)
            {
                package.PackageProperties.ContentType = contentType;
            }
            DateTime? created = Created;
            if (created != null)
            {
                package.PackageProperties.Created = created;
            }
            string creator = Creator;
            if (String.IsNullOrEmpty(creator) == false)
            {
                package.PackageProperties.Creator = creator;
            }
            string description = Description;
            if (String.IsNullOrEmpty(description) == false)
            {
                package.PackageProperties.Description = description;
            }
            string identifier = Identifier;
            if (String.IsNullOrEmpty(identifier) == false)
            {
                package.PackageProperties.Identifier = identifier;
            }
            string keywords = Keywords;
            if (String.IsNullOrEmpty(keywords) == false)
            {
                package.PackageProperties.Keywords = keywords;
            }
            string language = Language;
            if (String.IsNullOrEmpty(language) == false)
            {
                package.PackageProperties.Language = language;
            }
            string lastModifiedBy = LastModifiedBy;
            if (String.IsNullOrEmpty(lastModifiedBy) == false)
            {
                package.PackageProperties.LastModifiedBy = lastModifiedBy;
            }
            DateTime? lastPrinted = LastPrinted;
            if (lastPrinted != null)
            {
                package.PackageProperties.LastPrinted = lastPrinted;
            }
            DateTime? modified = Modified;
            if (modified != null)
            {
                package.PackageProperties.Modified = modified;
            }
            string revision = Revision;
            if (String.IsNullOrEmpty(revision) == false)
            {
                package.PackageProperties.Revision = revision;
            }
            string subject = Subject;
            if (String.IsNullOrEmpty(subject) == false)
            {
                package.PackageProperties.Subject = subject;
            }
            string title = Title;
            if (String.IsNullOrEmpty(title) == false)
            {
                package.PackageProperties.Title = title;
            }
            string version = Version;
            if (String.IsNullOrEmpty(version) == false)
            {
                package.PackageProperties.Version = version;
            }
            return base.Execute(executionContext);
        }   
	}
}
